function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; } function getStudentStatementCode ( name, grade, statement, photo_url ) { // alert(photo_url); return "
\"\"

"+name+"

"+grade+"

«"+statement+"»
"; } function updateStudentStatementCode ( json ) { var index = getRandomInt(0,json.length-1); var student_statement_html = getStudentStatementCode( json[index].title, json[index].entity_id_1, json[index].entity_id, json[index].entity_id_2['src'] ); jQuery('#students_statements_text').html( student_statement_html ); jQuery('#students_statements_text').fadeIn("fast"); } jQuery.getJSON("/students_about_lyceum_v2.json", function(json) { var student_statements_json = json; jQuery(document).ready(function() { jQuery('#students_statements_text').hide(); updateStudentStatementCode (json); jQuery('#students_statements').click(function() { jQuery('#students_statements_text').fadeOut("fast", function() { updateStudentStatementCode ( student_statements_json ); }); }); }); });